//
//  RadiateView.m
//  JunZeWristband
//
//  Created by Kendama on 2017/9/6.
//  Copyright © 2017年 DT. All rights reserved.
//

#import "RadiateView.h"

@implementation RadiateView

- (UIImageView *)bgImageView
{
    if(!_bgImageView)
    {
        UIView *superView = self;
        _bgImageView = [[UIImageView alloc]init];
        [superView addSubview:_bgImageView];
        _bgImageView.image = [UIImage imageNamed:@"bg_radiat"];
    }
    return _bgImageView;
}
- (UIImageView *)circleBgView
{
    if(!_circleBgView)
    {
        UIView *superView = self;
        _circleBgView = [[UIImageView alloc]init];
        [superView addSubview:_circleBgView];
        _circleBgView.image = [UIImage imageNamed:@"bg_radiate"];
    }
    return _circleBgView;
}
- (UIImageView *)circleView
{
    if(!_circleView)
    {
        UIView *superView = self;
        _circleView = [[UIImageView alloc]init];
        [superView addSubview:_circleView];
        _circleView.image = imageWithName(@"gif_blue");
    }
    return _circleView;
}

- (JXButton *)radiateKnowledgeButton
{
    if(!_radiateKnowledgeButton)
    {
        UIView *superView = self;
        _radiateKnowledgeButton = [[JXButton alloc]init];
        [superView addSubview:_radiateKnowledgeButton];
        [_radiateKnowledgeButton setTitle:MyNSLocalizedString(@"辐射知识") forState:UIControlStateNormal];
        [_radiateKnowledgeButton setImage:[UIImage imageNamed:@"but_know_nor"] forState:UIControlStateNormal];
        [_radiateKnowledgeButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
//        [_radiateKnowledgeButton.titleLabel setFont:[UIFont systemFontOfSize:15]];
//        [_radiateKnowledgeButton layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleTop imageTitleSpace:70];

    }
    return _radiateKnowledgeButton;
}
- (JXButton *)preventRadiateButton
{
    if(!_preventRadiateButton)
    {
        UIView *superView = self;
        _preventRadiateButton = [[JXButton alloc]init];
        [superView addSubview:_preventRadiateButton];
        [_preventRadiateButton setTitle:MyNSLocalizedString(@"预防辐射") forState:UIControlStateNormal];
        [_preventRadiateButton setImage:[UIImage imageNamed:@"but_prevent_nor"] forState:UIControlStateNormal];
        [_preventRadiateButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
//        [_preventRadiateButton.titleLabel setFont:[UIFont systemFontOfSize:15]];
//        [_preventRadiateButton layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleTop imageTitleSpace:70];

    }
    return _preventRadiateButton;
}

//[self.leftButton layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleLeft imageTitleSpace:0];

- (UILabel *)radiateLabel
{
    if(!_radiateLabel)
    {
        UIView *superView = self;
        _radiateLabel = [[UILabel alloc]init];
        [superView addSubview:_radiateLabel];
        [_radiateLabel setFont:[UIFont systemFontOfSize:40]];
        [_radiateLabel setTextColor:colorWithAlpha(107, 202, 249, 1)];
        _radiateLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _radiateLabel;
}

- (UILabel *)unitLabel
{
    if(!_unitLabel)
    {
        UIView *superView = self;
        _unitLabel = [[UILabel alloc]init];
        [superView addSubview:_unitLabel];
        [_unitLabel setFont:[UIFont systemFontOfSize:15]];
        [_unitLabel setTextColor:colorWithAlpha(107, 202, 249, 1)];
    }
    return _unitLabel;
}

- (UILabel *)tipLabel
{
    if(!_tipLabel)
    {
        UIView *superView = self;
        _tipLabel = [[UILabel alloc]init];
        [superView addSubview:_tipLabel];
        [_tipLabel setFont:[UIFont systemFontOfSize:15]];
        [_tipLabel setTextColor:[UIColor grayColor]];
        _tipLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _tipLabel;
}


- (void)masLayoutSubview
{
    __weak UIView *superView = self;
    [self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(superView.mas_top);
        make.left.right.mas_equalTo(superView);
        make.height.mas_equalTo(px1920Height(1030));
    }];
    
    [self.circleBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(superView.mas_top).with.offset(px1920Height(100));
        make.centerX.mas_equalTo(superView.mas_centerX);
        make.height.width.mas_equalTo(px1920Height(800));
    }];
    
    [self.circleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.circleBgView);
        make.height.width.mas_equalTo(px1920Height(500));
    }];
    
    [self.radiateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.circleView);

    }];
    
    [self.unitLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(self.radiateLabel.mas_bottom).with.offset(px1080Width(-40));
        make.left.mas_equalTo(self.radiateLabel.mas_right).with.offset(px1080Width(20));
    }];
    
    
    [self.tipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.radiateLabel);
        make.top.mas_equalTo(self.radiateLabel.mas_bottom).with.offset(px1920Height(20));
    }];
    
    [self.radiateKnowledgeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(superView.mas_bottom).with.offset(px1920Height(-600));
//        make.right.mas_equalTo(superView.mas_centerX).with.offset(px1080Width(-100));
        make.centerX.mas_equalTo(superView.mas_left).with.offset(SCREEN_WIDTH/4);
    }];
    
    [self.preventRadiateButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(superView.mas_bottom).with.offset(px1920Height(-600));
//        make.left.mas_equalTo(superView.mas_centerX).with.offset(px1080Width(100));
        make.centerX.mas_equalTo(superView.mas_left).with.offset(SCREEN_WIDTH*3/4);
    }];
    
    
    self.radiateLabel.text = @"0";
    self.tipLabel.text = MyNSLocalizedString(@"安全范围值");
    self.unitLabel.text = @"μT";
    
    
}


@end
